import java.util.*;

/**
 * @Author: qiuShiHao
 * @Date: 2022/3/14 9:59
 */

public class 第10届省赛B {

    /*不同子串*/
    static void a1(){
        String s = "0100110001010001";
        char[] chars = s.toCharArray();
        Set<String> set = new HashSet<>();
        for (int i = 0; i <chars.length ; i++) {
            String s1 = "";
            for (int j = i+1; j <chars.length ; j++) {
                 s1=s1+String.valueOf(chars[i]) + String.valueOf(chars[j]);
                System.out.println(s1);
                 set.add(s1);
            }
        }
        System.out.println(set.size());
    }
    static void a2() {
        String s = "0100110001010001";
        Set<String> set = new HashSet<>();
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j <= s.length(); j++) {
                String s1 = s.substring(i, j);
                System.out.println(s1);
                set.add(s1);
            }
        }
        System.out.println(set.size());
    }

    /*数列求值*/
    static void b1(){
        int [] a = new int [4];
        a[0] = 1;
        a[1] = 1;
        a[2] = 1;
        int sum=0;
        for(int i=3;i<20190324;i++)
        {
            sum = i%4;//当到第五项时，又回到第一项存
            a[sum] =( a[(sum+4-1)%4]+a[(sum+4-2)%4]+a[(sum+4-3)%4])%10000;
        }
        System.out.print(a[sum]);
    }
    static void b2(){
        int a = 1, b = 1, c = 1;
        // 要是求第四项，则i < 4, 同理推得求20190324，则i < 20190324。
        for (int i = 3; i < 20190324; i++) {
            int temp = (a + b + c) % 10000;//直接计算整个数值会导致溢出结果不正确
            a = b;
            b = c;
            c = temp;
        }
        System.out.println(c);
    }

    /*数的分解*/
    static void c(){
        int count=0;
        for(int i=1;i<=2019;i++) {
            for(int j=1;j<=2019;j++) {
                for(int k=1;k<=2019;k++) {
                    if(i+j+k==2019&&judge(i)&&judge(j)&&judge(k)&&i!=j&&j!=k&&i!=k) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count/6);
    }
    public static boolean judge(int n) {
        while(n>0) {
            if(n%10==2||n%10==0||n%10==1||n%10==9) {
                return true;
            }
            n/=10;
        }
        return false;
    }

    /*迷宫*/
    static void d(){

    }

    /*特别数的和*/
    static void e(){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int sum = 0;
        for (int i = 0; i <=a ; i++) {
            if (judge(i)){
                System.out.println(i);
                sum=sum+i;
            }
        }
        System.out.println(sum);
    }

    /*外卖店优先级*/
    static class Order{
        private int time;
        private int no;
        public Order(int time,int no){
            this.time=time;
            this.no=no;
        }
    }
    static void f(){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int T = scanner.nextInt();
        int[] priority = new int[N];//保存最后时刻店铺的优先级
        int result = 0;

        List<Order> list = new ArrayList<>();//存放订单
        List<Integer> temp = new ArrayList<>();//保存某一时刻有订单的店铺
        for (int i = 0; i <M ; i++) {
            list.add(new Order(scanner.nextInt(),scanner.nextInt()));
        }

        for (int i = 1; i <=T ; i++) {//遍历每个时刻的订单
            temp.clear();
            for (Order order : list) {
                if (order.time == i)
                {
                    priority[order.no-1]+=2;
                    temp.add(order.no-1);
                }
            }

            for (int j = 0; j <N ; j++) {//某一时刻没有订单的商家优先级下降
                if (!temp.contains(j)){
                    if (priority[j]>0)priority[j]--;
                }
            }
        }

        for (int i = 0; i <N ; i++) {
            System.out.println(priority[i]);
            if (priority[i]>5)result++;
        }

        System.out.println(result);
    }

    /*人物相关性分析*/
    static void g(){
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        scanner.nextLine();//获取回车符
        String string = scanner.nextLine();
//        System.out.println(string);
        String[] arr = string.split("\\s+|\\.+|\\,");
        int count = 0;

        for (int i = 0; i <arr.length ; i++) {
            if (arr[i].equals("Alice")){
                int sum = 1;
                for (int j = i+1; j < arr.length ; j++) {
                    sum+=arr[j].length()+1;
                    if (arr[j].equals("Bob")){
                        if (sum<20)count++;
                    }
                }
            }
        }

        for (int i = 0; i <arr.length ; i++) {
            if (arr[i].equals("Bob")){
                int sum = 1;
                for (int j = i+1; j < arr.length ; j++) {
                    sum+=arr[j].length()+1;
                    if (arr[j].equals("Alice")){
                        if (sum<20)count++;
                    }
                }
            }
        }
        System.out.println(count);
    }

    /*后缀表达式*/
    static void h(){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[] arr = new  int[N+M+1];
        for (int i = 0; i <N+M+1 ; i++) {
            arr[i]=scanner.nextInt();
        }
    }



    public static void main(String[] args) {
        h();
    }

}
